//
//  PortraitCell.m
//  HTHappySale
//
//  Created by 创维海通 on 2017/9/21.
//  Copyright © 2017年 zxyywy. All rights reserved.
//

#import "PortraitCell.h"

//Tools
#import "UIImageView+WebCache.h"
@interface PortraitCell()
@property (strong, nonatomic) IBOutlet UILabel *title;
@property (strong, nonatomic) IBOutlet UIImageView *headImg;

@end

@implementation PortraitCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)configureCell:(UserInfoModel *)model
{
    _title.text = @"头像";
    _headImg.layer.masksToBounds = YES;
    _headImg.layer.cornerRadius = _headImg.frame.size.width/4;

    NSString *filePath = HTCFAppCacheDirectory;
    NSString *filePath2 = [NSString stringWithFormat:@"%@%@",filePath,@"/MyImage/pic.png"];
    
    NSString *ImgStr;
    if (!HTCFCheckObjectNull(model.portrait)) {
        ImgStr = [NSString stringWithFormat:@"%@%@",Img_URL,HTCFUDFGetValue(kPortraitKey)];
    }
    
    if(HTCFFileIsExist(filePath2)){
        NSData *data = [NSData dataWithContentsOfFile:filePath2];
        NSLog(@"%@",data);
        UIImage *image = [UIImage imageWithData:data];
        [_headImg setImage:image];
    }else if (ImgStr != nil && ImgStr.length >0)
    {
        [_headImg sd_setImageWithURL:[NSURL URLWithString:ImgStr] placeholderImage:HTCFQuickImage(@"Headportrait")];
    }else{
        _headImg.image = HTCFQuickImage(@"Headportrait");
    }
}

@end
